/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package schedulerManagerment.SeekerManager.entities;

import connection.Configuration;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Tngoc
 */
public class Seeker {
    private int id;
    private String name;
    private Date dateOfBirth;
    private boolean gender;
    private Field field;
    private int status;
    private String email;
    private String address;
    private String phone;
    private String website;
    private String location;
    private ArrayList<Skill> skills;

    public Seeker() {
        skills = new ArrayList<>();
    }

    public ArrayList<Skill> getSkills() {
        return skills;
    }

    public void setSkills(ArrayList<Skill> skills) {
        this.skills = skills;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Date getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Field getField() {
        return field;
    }

    public void setField(Field field) {
        this.field = field;
    }

    public boolean isGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        try {
            this.id = id;
            skills.clear();
            Connection conn = new Configuration().getConnect();
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery("select Skill.name as name,Skill.ID as id from Skill,SeekerSkill_Detail where SeekerSkill_Detail.SkillID=Skill.ID and SeekerSkill_Detail.SeekerID="+id);
            
            while(rs.next()){
                Skill s = new Skill(rs.getInt("id"), rs.getString("name"));
                skills.add(s);
            }
            rs.close();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(Seeker.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }
    
}
